function showImage(url) {
  jQuery('#win_observation_image').attr('src', url);
  var $dialog = jQuery("#div_win_observation_image");
  $dialog.dialog('open');
}

function deleteImage(elem, oid, id) {
  var cont = confirm('Are you sure you want to delete this image?');
  if (!cont) {
    return;
  }

  var data = new Object();
  data.oid = oid;
  data.img_id = id;
  var obj = new Object();
  obj.action = 'deleteImage';
  obj.params = data;
  var json_data = JSON.stringify(obj);

  var url = Drupal.settings.basePath + 'observation/data';
  jQuery.ajax({
    type: "POST",
    async: false,
    url: url,
    data: {request: json_data},
    success: function(data) {
      //alert(data);
      data = JSON.parse(data);
      if (parseInt(data.error) == 1) {
        displayMessage('error', data.msg);
        return false;
      }
      else {
        url = window.location.href;
        window.location.replace(url);
        // var elem_galbox = jQuery(elem).parent().parent();
        // elem_galbox.remove();

        // var uploadedImages = jQuery('#uploadedImages');
        // var len = uploadedImages.children();
        // if (len < 2) {
          // uploadedImages.find(input).attr('disabled', 'disabled');
        // }
      }
    },
    error: function(data) {
      //alert(data);
    }
  });
}

jQuery(document).ready(function(){
  var $dialog = jQuery("#div_win_observation_image");
  $dialog.dialog({
    autoOpen: false,
    modal: true,
    minHeight: 150,
    minWidth: 400,
    maxWidth: 1200,
    maxHeight: 500,
    width: 800,
    height: 400
  });
});